package com.koron.order.common.controller;

import com.github.pagehelper.PageInfo;
import com.koron.bean.base.Response;
import com.koron.bean.query.PageQuery;
import com.koron.common.core.config.ThreadLocalContext;
import com.koron.order.common.bean.po.OrderEquipmentPo;
import com.koron.order.common.service.OrderEquipmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * (OrderEquipment)表控制层
 *
 * @author zhouj
 * @since 2021-11-09 18:50:33
 */
@Api(tags = "工单关联的设备")
@RestController
@RequestMapping("/orderEquipment/")
public class OrderEquipmentController {

    @Autowired
    private OrderEquipmentService orderEquipmentService;

    private String getCurrDs() {
        return ThreadLocalContext.get().getCurrDs();
    }

    @ApiOperation(value = "根据id查询")
    @GetMapping("queryById")
    public Response<List> queryById(String id) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderEquipmentService, "queryById", List.class, id));
    }

    @ApiOperation(value = "不分页查询列表")
    @GetMapping("queryList")
    public Response<List> queryList(OrderEquipmentPo queryVo) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderEquipmentService, "queryList", List.class, queryVo));
    }

    @ApiOperation(value = "分页查询列表")
    @GetMapping("queryPageList")
    public Response<PageInfo> queryPageList(OrderEquipmentPo queryPo, PageQuery pageQuery) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderEquipmentService, "queryPageList", PageInfo.class, queryPo, pageQuery));
    }

    @ApiOperation(value = "设备维修统计")
    @GetMapping("maintenanceStat")
    public Response<Map<String, Integer>> maintenanceStat(OrderEquipmentPo queryPo) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), orderEquipmentService, "maintenanceStat", Map.class, queryPo));
    }
}
